import json

import requests
from werobot.client import Client
from utils.Robot.config import Menu_Data, AppID, Access_Token, EncodingAESKey, AppSecret


def create_menu():
    config = {
        "token" : Access_Token,
        "encoding_aes_key" : EncodingAESKey,
        "APP_ID" : AppID,
        "APP_SECRET" : AppSecret,
    }
    menu = Client(config=config)
    AccessToken = menu.grant_token().get('access_token')
    print(AccessToken)
    AccessUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="
    Json_Data = json.dumps(Menu_Data)
    response = requests.post(AccessUrl + AccessToken, json=Json_Data)
    # response = menu.create_menu(Menu_Data)
    return response

